@extends("home.public.home")

@section("content")
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="/style/home/css/home/upload.css">
  <script src="/style/home/js/user/email.js"></script>
  <!-- <script src="/style/home/js/user/upload.js"></script> -->
  <script src="/style/home/js/user/area.js"></script>
   <!---图片上传插件-->
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="/up/uploadify.css">
    <script type="text/javascript" src="/up/jquery.uploadify.min.js"></script>
  <meta name="csrf-token" content="{{ csrf_token() }}">


<div class="msg_right">
        <!-- 个人资料 -->
       <div class="msg_box">
            <div class="msg_title">
                <p>个人信息</p>
            </div>
            <div class="msg_main clearfix">
                <form id="infoform" action="/user" method="post">
                    <ul class="clearfix msg_ul">
                        <li class="clearfix msg_li">
                            <p class="msg_name">会员账号：</p>
                            <p>{{Cookie::get('user')['tel']}}</p>
                        </li>
                        <li class="clearfix msg_li">
                            <p class="msg_name"><span class="msg_red">* </span>会员昵称：</p>
                            <p><input type="text" id="username" name="username" class="msg_input_w" value="{{$data['nickname']}}"></p>
                            <p class="msg_text">4-20个字符，可由中英文、数字、“_”、“-”组成</p>
                        </li>
                        <li class="clearfix msg_sex msg_li">
                            <p class="msg_name"><span class="msg_red">* </span>性别：</p>
                            <p>
                                <input type="radio" name="gender" @if($data['sex']==1) checked @endif id="sex-man" value="1"><label for="sex-man">男</label>
                                    <input type="radio" name="gender" id="sex-woman" @if($data['sex']==0) checked @endif value="0"><label for="sex-woman">女</label>
                                </p>
                        </li>
                        <li class="clearfix msg_li">
                            <p class="msg_name"><span class="msg_red">* </span>生日：</p>
                            <p>
                                <input type="text" id="birthday" value="{{$data['birthday']}}">
                                <script src="/style/home/laydate/laydate.js"></script> <!-- 改成你的路径 -->
                                <script>
                                //执行一个laydate实例
                                laydate.render({
                                  elem: '#birthday' //指定元素
                                });
                                </script>
                            </p>
                        </li>

                         <li class="clearfix msg_li">
                            <p class="msg_name"><span class="msg_red"> </span>绑定邮箱</p>
                            <p>
                                <input type="text" name="realname" id="emailval" class="msg_input_w"  value="{{$user['email']}}" @if($user['email']) disabled @endif>
                            </p>
                            @if(!$user['email'])
                            <p class="msg_text">绑定邮箱可以使用邮箱登录</p><input type="button" id="email" value="点击绑定邮箱" />
                            @endif
                        </li>
                        </li>
                         <li class="clearfix msg_li">
                            <p class="msg_name"><span class="msg_red"> </span>所在地址</p>
                            <p>
                            <select id="Province" runat="server" name="province" style="width: 90px" >
                            </select>
                            <select id="Country" runat="server" name="country" style="width: 90px"></select>
                            <select id="Town" runat="server" name="town" style="width: 90px"></select>

                            <script language="javascript">
                            setup();
                            </script>
                            </li>
                        <li class="clearfix msg_li">
                            <p class="msg_name"><span class="msg_red"> </span>详细地址：</p>
                            <p><input type="text" name="residecommunity" id="residecommunity" class="msg_input_w" style="width:412px;" maxlength="100" value="{{$data['addrInfo']}}"></p>
                        </li>
                        </ul>
                 </form>

    <!-- 修改头像 -->
            <div style="float:left;margin-left:100px;">

            <form action="/userContentdata/{{$user['id']}}" method="post" enctype='multipart/form-data' >
                      {{csrf_field()}}
                      <input type="hidden" value="PUT" name="_method">
                <dl >
                    <dt>
                        @if($data['photo']=='')

                        <div id="main">
                            <img src="//i.app.lefile.cn/head/pic12654372/s12654372_1503415157931.4x1-w7xh7.w100.jpg?t1503415158325" alt="修改头像" title="修改头像">
                        </div>
                        @else

                        <div id="main">
                            <img src="{{$data['photo']}}" alt="修改头像" title="修改头像">
                        </div>
                        @endif

                        <input type="file" name="" id="uploads">
                        <input type="hidden" name="photo" id="photos">
                        <input type="submit"  value="提交">
                    </dt>


                </dl>
                </form>
            </div>


                </div>
                    <div class="msg_likes_mainl">
                        <p>&nbsp;</p>

            <div class="msg_likes_mains">
                <div class="msg_likes_main clearfix">
                    </div>
                    <div class="msg_likes_btn">
                        <ul>
                            <li id="pushedit" onmouseover="this.style.background='#FF3030'" onmouseout="this.style.background='#c9c9c9'" style="font-size: 14px;cursor: pointer;">修改</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <!-- 兴趣资料 -->
        </div>

        <script>
            $(function()
{
    $("#pushedit").click(function()
    {
        $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                 async: false
            });


        var arr=new Array();
        arrnickname=$("#username").val();
        arrsex=$("input:radio:checked").val();
        arrbirthday=$("#birthday").val();
        arraddrInfo=$("#residecommunity").val();
        arraddr=$("#Province").val()+"-"+$("#Country").val()+"-"+$("#Town").val();;

        $.post("/homealter",{"nickname":arrnickname,"sex":arrsex,"birthday":arrbirthday,"addrInfo":arraddrInfo,"addr":arraddr},function(msg)
            {
                if(msg==1){
                    alert("修改成功");
                }else{
                    alert("修改失败");
                }

            });
        // console.log(arr);

    })
})


        </script>
        <script>
    $(function() {
        // 声明字符串

        var photos="";
        // 使用 uploadify 插件
        $('#uploads').uploadify({
            // 设置文本
            'buttonText' : '修改头像',
            // 设置文件传输数据
            'formData'     : {
                '_token':'{{ csrf_token() }}',
                'files':'user',

            },
            // 上传的flash动画
            'swf'      : "/up/uploadify.swf",
            // 文件上传的地址
            'uploader' : "/admin/shangchuan",
            // 当文件上传成功
            'onUploadSuccess' : function(file, data, response) {
                // // 拼接图片
                imgs="<img width='200px' src='/Uploads/user/"+data+ "'>";


                // 展示图片
                $("#main").html(imgs);
                // 隐藏传递数据
                $("#photos").val(data);

            }
        });
    });
</script>

@endsection